package org.fisco.bcos.evidence.gateway.controller;

import org.fisco.bcos.evidence.gateway.config.Response;
import org.springframework.stereotype.Controller;

@Controller
public class BaseController {
    //获取正确
    public Response successResponse(String message, Object result) {
        if (message == null) message = "处理成功";
        Response response = new Response();
        response.setSuccess(Response.SUCCEED);
        response.setMessage(message);
        if (result == null)
            result = 1;
        response.setResult(result);
        return response;
    }

    //出现错误
    public Response errorResponse(String message, Object result) {
        if (message == null) message = "处理失败";
        Response response = new Response();
        response.setSuccess(Response.ERROR);

        if (result == null)
            result = 0;
        else {
            response.setMessage(message);
            response.setResult(result);
        }
        return response;
    }
}
